$(function() {
    echart_3();

    //重点医院
    $.ajax({
        url: "../../../Message/hospCollect",
        dataType: "json",
        type: "post",
        success: function(res) {
            var j = res.data;
            var str = '';
            var l = j.length > 4 ? 4 : j.length;
            for (var i = 0; i < l; i++) {
                var k = j[i][7];
                str += "<div>";
                str += "<img src='../../layuiadmin/layui/images/hospital/yy" + j[i][8] + ".jpg' alt=''></img>";
                if (k.length > 10) {
                    var c = Math.ceil(k.length / 2);
                    str += "<h3>" + k.substring(0, c) + "</br>" + k.substring(c) + "</h3>";
                } else {
                    str += "<h3>" + j[i][7] + "</h3>";
                }
                str += "</div>"
            }
            $("#hosp").prepend(str);
            echart_1(j[0][0], j[0][1], j[0][2], j[0][3], j[0][4], j[0][5]);
            layui.use('carousel', function() {
                var carousel = layui.carousel;
                //建造实例
                carousel.render({
                    elem: '#test1',
                    width: '90%' //设置容器宽度
                        ,
                    arrow: 'hover' //始终显示箭头
                        //,anim: 'updown' //切换动画方式
                        ,
                    interval: 30000,
                    autoplay: true,
                    height: '3.6rem'
                });
                carousel.on('change(test1)', function(obj) { //test1来源于对应HTML容器的 lay-filter="test1" 属性值
                    var index = obj.index;
                    var a1 = parseFloat(j[index][0]); //grx
                    var a2 = parseFloat(j[index][1]); //ssx
                    var a3 = parseFloat(j[index][2]); //hxx
                    var a4 = parseFloat(j[index][3]); //ywx
                    var a5 = parseFloat(j[index][4]); //blx
                    var a6 = (parseFloat(j[index][5]) + parseFloat(j[index][6])); //syp syd
                    echart_1(a1, a2, a3, a4, a5, a6);
                });
            });
        }
    })

    function is0ornot(num) {
        if (parseFloat(num) == 0) {
            return 0
        } else {
            return parseFloat(num).toFixed(2);
        }
    }

    function echart_1(a1, a2, a3, a4, a5, a6) {
        // 基于准备好的dom，初始化echarts实例
        a1 = is0ornot(a1);
        a2 = is0ornot(a2);
        a3 = is0ornot(a3);
        a4 = is0ornot(a4);
        a5 = is0ornot(a5);
        a6 = is0ornot(a6);
        var myChart = echarts.init(document.getElementById('chart_1'));
        option = {
            color: ['#CD4F62', '#E08F18', '#5CA8BB', '#5D9D1D', '#704FCB', '#707474'],
            tooltip: {
                trigger: 'item',
                formatter: "{b}: {c} 公斤({d}%)",

            },
            legend: {
                top: '80%',
                data: ['感染性', '损伤性', '药物性', '病理性', '化学性', '其他'],
                textStyle: {
                    color: '#fff'
                }
            },
            series: [

                {
                    name: '收集量',
                    type: 'pie',
                    radius: ['40%', '55%'],
                    label: {
                        normal: {
                            formatter: '{b|{b}}\n {c}',
                            borderRadius: 4,
                            rich: {
                                b: {
                                    fontSize: 12
                                },
                            }
                        }
                    },
                    data: [
                        { value: a1, name: '感染性' },
                        { value: a2, name: '损伤性' },
                        { value: a4, name: '药物性' },
                        { value: a5, name: '病理性' },
                        { value: a3, name: '化学性' },
                        { value: a6, name: '其他' }
                    ]
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    }
    $.ajax({
        url: "../../../Message/monthCollect",
        dataType: "json",
        type: "post",
        success: function(res) {
            var data = res.data;
            var month = [];
            var values = [];
            for (var i = 0; i < data.length; i++) {
                for (x in data[i]) {
                    var a = x.split("-");
                    month[i] = a[1] + "月";
                    if (data[i][x] == "" || data[i][x] == null) {
                        values[i] = 0
                    } else {
                        values[i] = parseFloat(data[i][x]).toFixed(2)
                    }
                }
            }
            echart_2(month, values)
        }
    })

    function echart_2(month, values) {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_2'));
        var data = {
            id: 'multipleBarsLines',

            xAxis: month,
            yAxis: [
                values
            ],
            lines: [
                values
            ],
            // xAxis: ['7月', '8月', '9月', '10月', '11月', '12月'],
            // yAxis: [
            //     [15, 10, 14, 11, 7, 16]
            // ],
            // lines: [
            //     [15, 10, 14, 11, 7, 16]
            // ],
            barColor: ['#3FA7DC', '#7091C4', '#5170A2'], //柱子颜色 必填参数
            lineColor: ['#D9523F'], // 折线颜色

        };
        /////////////end/////////

        var myData = (function test() {
            var yAxis = data.yAxis || [];
            var lines = data.lines || [];
            var legendBar = data.legendBar || [];
            var legendLine = data.legendLine || [];
            var symbol = data.symbol || ' ';
            var seriesArr = [];
            var legendArr = [];
            yAxis && yAxis.forEach((item, index) => {
                legendArr.push({
                    name: legendBar && legendBar.length > 0 && legendBar[index]
                });
                seriesArr.push({
                    name: legendBar && legendBar.length > 0 && legendBar[index],
                    type: 'bar',
                    barGap: '0.5px',
                    data: item,
                    barWidth: data.barWidth || 12,
                    label: {
                        normal: {
                            show: true,
                            formatter: '{c}',
                            position: 'top',
                            textStyle: {
                                color: '#fff',
                                fontStyle: 'normal',
                                textAlign: 'left',
                                fontSize: 13,
                            },
                        },
                    },
                    itemStyle: { //图形样式
                        normal: {
                            barBorderRadius: 4,
                            color: data.barColor[index]
                        },
                    }
                });
            });

            lines && lines.forEach((item, index) => {
                legendArr.push({
                    name: legendLine && legendLine.length > 0 && legendLine[index]
                })
                seriesArr.push({
                    name: legendLine && legendLine.length > 0 && legendLine[index],
                    type: 'line',
                    data: item,
                    itemStyle: {
                        normal: {
                            color: data.lineColor[index],
                            lineStyle: {
                                width: 3,
                                type: 'solid',
                            }
                        }
                    },
                    label: {
                        normal: {
                            show: false, //折线上方label控制显示隐藏
                            position: 'top',
                        }
                    },
                    symbol: 'circle',
                    symbolSize: 10
                });
            });

            return {
                seriesArr,
                legendArr
            };
        })();


        option = {
                title: {
                    show: true,
                    top: '10%',
                    left: '3%',
                    text: data.title,
                    textStyle: {
                        fontSize: 18,
                        color: '#fff'
                    },
                    subtext: data.subTitle,
                    link: ''
                },
                tooltip: {
                    trigger: 'axis',
                    formatter: function(params) {
                        var time = '';
                        var str = '';
                        for (var i of params) {
                            time = i.name.replace(/\n/g, '') + '<br/>';
                            if (i.data == 'null' || i.data == null) {
                                str += i.seriesName + '：无数据' + '<br/>';
                                break;
                            } else {
                                str += '收集量：' + i.data + '公斤<br/>';
                                break;
                            }

                        }
                        return time + str;
                    },
                    axisPointer: {
                        type: 'none'
                    },
                },
                legend: {
                    right: data.legendRight || '30%',
                    top: '12%',
                    right: '5%',
                    itemGap: 16,
                    itemWidth: 10,
                    itemHeight: 10,
                    data: myData.legendArr,
                    textStyle: {
                        color: '#fff',
                        fontStyle: 'normal',
                        fontFamily: '微软雅黑',
                        fontSize: 12,
                    }
                },
                grid: {
                    x: 30,
                    y: 80,
                    x2: 30,
                    y2: 60,
                },
                xAxis: {
                    type: 'category',
                    data: data.xAxis,
                    axisTick: {
                        show: false,
                    },

                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#1AA1FD',
                        },
                        symbol: ['none', 'arrow']
                    },
                    axisLabel: {
                        show: true,
                        interval: '0',
                        textStyle: {
                            lineHeight: 16,
                            padding: [2, 2, 0, 2],
                            height: 50,
                            fontSize: 12,
                        },
                        rich: {
                            Sunny: {
                                height: 50,
                                // width: 60,
                                padding: [0, 5, 0, 5],
                                align: 'center',
                            },
                        },
                        formatter: function(params, index) {
                            var newParamsName = "";
                            var splitNumber = 5;
                            var paramsNameNumber = params && params.length;
                            if (paramsNameNumber && paramsNameNumber <= 4) {
                                splitNumber = 4;
                            } else if (paramsNameNumber >= 5 && paramsNameNumber <= 7) {
                                splitNumber = 4;
                            } else if (paramsNameNumber >= 8 && paramsNameNumber <= 9) {
                                splitNumber = 5;
                            } else if (paramsNameNumber >= 10 && paramsNameNumber <= 14) {
                                splitNumber = 5;
                            } else {
                                params = params && params.slice(0, 15);
                            }

                            var provideNumber = splitNumber; //一行显示几个字
                            var rowNumber = Math.ceil(paramsNameNumber / provideNumber) || 0;
                            if (paramsNameNumber > provideNumber) {
                                for (var p = 0; p < rowNumber; p++) {
                                    var tempStr = "";
                                    var start = p * provideNumber;
                                    var end = start + provideNumber;
                                    if (p == rowNumber - 1) {
                                        tempStr = params.substring(start, paramsNameNumber);
                                    } else {
                                        tempStr = params.substring(start, end) + "\n";
                                    }
                                    newParamsName += tempStr;
                                }

                            } else {
                                newParamsName = params;
                            }
                            params = newParamsName;
                            return '{Sunny|' + params + '}';
                        },
                        color: '#1AA1FD',
                    },

                },
                yAxis: {
                    axisLine: {
                        show: true,
                        lineStyle: {
                            color: '#1AA1FD',
                        },
                        symbol: ['none', 'arrow']
                    },
                    type: 'value',
                    axisTick: {
                        show: false
                    },
                    axisLabel: {
                        show: false
                    },
                    splitLine: {
                        show: false,
                        lineStyle: {
                            color: '#1AA1FD',
                            type: 'solid'
                        },
                    }
                },
                series: myData.seriesArr
            }
            // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    }

    function echart_3() {
        // 基于准备好的dom，初始化echarts实例
        var colors = [
            "#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00",
            "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707",
            "#651067", "#329262", "#5574a6", "#3b3eac"
        ];
        var myChart = echarts.init(document.getElementById('chart_3'));
        var marker;
        var infoWindow;
        var content;
        var lng = [120.169329, 120.180895, 120.242252, 120.141406, 120.108059, 120.211816, 120.264253, 120.299402, 119.691434, 119.281213, 119.960076, 119.724733, 119.041864]; //经度
        var lat = [30.242312, 30.281714, 30.292295, 30.319037, 30.234114, 30.20856, 30.183806, 30.419045, 29.793535, 29.474884, 30.048692, 30.233873, 29.608772]; //纬度
        var area = ['上城区', '下城区', '江干区', '拱墅区', '西湖区', '滨江区', '萧山区', '余杭区', '桐庐县', '建德市', '富阳区', '临安区', '淳安县', '钱塘新区'];
        var i = 0;

        function showProvince() {
            $.ajax({
                url: "../../../Message/regionDayCollect",
                dataType: "json",
                type: "post",
                success: function(res) {
                    var data = res.data;
                    var map = new AMap.Map('chart_3', {
                        cursor: 'default',
                        zoom: 9,
                        mapStyle: 'amap://styles/9ab4483922efff6b2894220cadf30946'
                    });
                    //just some colors
                    // AMap.plugin(['AMap.ToolBar', 'AMap.Scale'], function() {
                    //     map.addControl(new AMap.ToolBar());
                    //     map.addControl(new AMap.Scale());
                    // })
                    marker = new AMap.Marker({
                        position: new AMap.LngLat(lng[0], lat[0]),
                        label: area[0]
                    });
                    marker.setLabel({ //label默认蓝框白底左上角显示，样式className为：amap-marker-label
                        offset: new AMap.Pixel(20, 20), //修改label相对于maker的位置
                        content: area[0]
                    });

                    content = "";
                    content = "<div class='map_f'>" + area[0] + "收集数据：";
                    content += "<div>感染性：" + is0ornot(data[0][0]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    content += "损伤性：" + is0ornot(data[0][1]) + "</div>"
                    content += "<div>药物性：" + is0ornot(data[0][3]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    content += "病理性：" + is0ornot(data[0][4]) + "</div>"
                    content += "<div>化学性：" + is0ornot(data[0][2]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                    content += "其他：" + is0ornot((parseFloat(data[i][6]) + parseFloat(data[i][5]))) + "</div>"
                    content += "</div>"
                    marker.content = content;
                    infoWindow = new AMap.InfoWindow({
                        offset: new AMap.Pixel(0, 0),
                        autoMove: true
                    });
                    marker.on('click', markerClick);

                    function markerClick(e) {
                        infoWindow.setContent(e.target.content);
                        infoWindow.open(map, e.target.getPosition());
                    }
                    infoWindow.setContent(content);
                    infoWindow.open(map, marker.getPosition());
                    // AMapUI.loadUI(['overlay/SimpleInfoWindow'], function(SimpleInfoWindow) {
                    //     var infoWindow = new SimpleInfoWindow({
                    //         infoTitle: '<strong>这里是标题</strong>',
                    //         infoBody: '<p>高德地图 JavaScript API，是由 JavaScript 语言编写的应用程序接口，' +
                    //             '它能够帮助您在网站或移动端中构建功能丰富、交互性强的地图应用程序</p>',
                    //         //基点指向marker的头部位置
                    //         offset: new AMap.Pixel(0, -31)
                    //     });

                    //     function openInfoWin() {
                    //         infoWindow.open(map, marker.getPosition());
                    //     }
                    //     openInfoWin();
                    // });
                    map.add(marker);


                    setInterval(function() {
                        map.remove(marker);
                        infoWindow.close();
                        if (i < lng.length - 1) {
                            i++
                        } else {
                            i = 0;
                        }
                        marker = new AMap.Marker({
                            position: new AMap.LngLat(lng[i], lat[i]),
                        });
                        marker.setLabel({ //label默认蓝框白底左上角显示，样式className为：amap-marker-label
                            offset: new AMap.Pixel(20, 20), //修改label相对于maker的位置
                            content: area[i]
                        });
                        content = "";
                        content = "<div class='map_f'>" + area[i] + "收集数据：";
                        content += "<div>感染性：" + is0ornot(data[i][0]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                        content += "损伤性：" + is0ornot(data[i][1]) + "</div>"
                        content += "<div>药物性：" + is0ornot(data[i][3]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                        content += "病理性：" + is0ornot(data[i][4]) + "</div>"
                        content += "<div>化学性：" + is0ornot(data[i][2]) + "&nbsp;&nbsp;&nbsp;&nbsp;"
                        content += "其他：" + is0ornot((parseFloat(data[i][6]) + parseFloat(data[i][5]))) + "</div>"
                        content += "</div>"
                        marker.content = content;
                        infoWindow = new AMap.InfoWindow({
                            offset: new AMap.Pixel(0, 0)
                        });
                        marker.on('click', markerClick);
                        infoWindow.setContent(content);
                        infoWindow.open(map, marker.getPosition());
                        map.add(marker);


                    }, 30000)

                    function getAllRings(feature) {

                        var coords = feature.geometry.coordinates,
                            rings = [];

                        for (var i = 0, len = coords.length; i < len; i++) {
                            rings.push(coords[i][0]);
                        }

                        return rings;
                    }

                    function getLongestRing(feature) {
                        var rings = getAllRings(feature);

                        rings.sort(function(a, b) {
                            return b.length - a.length;
                        });

                        return rings[0];
                    }
                    AMapUI.load(['ui/geo/DistrictExplorer', 'lib/$'], function(DistrictExplorer, $) {

                        //创建一个实例
                        var districtExplorer = window.districtExplorer = new DistrictExplorer({
                            eventSupport: true, //打开事件支持
                            map: map
                        });

                        //当前聚焦的区域
                        var currentAreaNode = null;

                        //鼠标hover提示内容
                        var $tipMarkerContent = $('<div class="tipMarker bottom"></div>');
                        var tipMarker = new AMap.Marker({
                            content: $tipMarkerContent.get(0),
                            offset: new AMap.Pixel(0, 0),
                            bubble: true
                        });

                        //根据Hover状态设置相关样式
                        function toggleHoverFeature(feature, isHover, position) {

                            tipMarker.setMap(isHover ? map : null);

                            if (!feature) {
                                return;
                            }

                            var props = feature.properties;



                            //更新相关多边形的样式
                            var polys = districtExplorer.findFeaturePolygonsByAdcode(props.adcode);
                            for (var i = 0, len = polys.length; i < len; i++) {

                                polys[i].setOptions({
                                    fillOpacity: isHover ? 0.9 : 0.6
                                });
                            }
                        }

                        //监听feature的hover事件
                        districtExplorer.on('featureMouseout featureMouseover', function(e, feature) {
                            toggleHoverFeature(feature, e.type === 'featureMouseover',
                                e.originalEvent ? e.originalEvent.lnglat : null);
                        });

                        //监听鼠标在feature上滑动
                        districtExplorer.on('featureMousemove', function(e, feature) {
                            //更新提示位置
                            tipMarker.setPosition(e.originalEvent.lnglat);
                        });

                        var countryCode = 100000, //全国
                            provCodes = [
                                330000, //浙江

                            ],
                            cityCodes = [

                                330100 //杭州
                            ];

                        districtExplorer.loadMultiAreaNodes(
                            //只需加载全国和市，全国的节点包含省级
                            [countryCode].concat(cityCodes),
                            function(error, areaNodes) {

                                var countryNode = areaNodes[0],
                                    cityNodes = areaNodes.slice(1);

                                var path = [];

                                //首先放置背景区域，这里是大陆的边界
                                path.push(getLongestRing(countryNode.getParentFeature()));




                                for (var i = 0, len = cityNodes.length; i < len; i++) {
                                    //逐个放置需要镂空的市级区域
                                    path.push.apply(path, getAllRings(cityNodes[i].getParentFeature()));
                                }

                                //绘制带环多边形
                                //http://lbs.amap.com/api/javascript-api/reference/overlay#Polygon
                                var polygon = new AMap.Polygon({
                                    bubble: true,
                                    lineJoin: 'round',
                                    strokeColor: 'red', //线颜色
                                    strokeOpacity: 0, //线透明度
                                    strokeWeight: 1, //线宽
                                    fillColor: '#0c1f34', //填充色
                                    fillOpacity: 0.9, //填充透明度
                                    map: map,
                                    path: path
                                });
                            });
                        var adcode = 330100;

                        districtExplorer.loadAreaNode(adcode, function(error, areaNode) {

                            //更新地图视野
                            map.setBounds(areaNode.getBounds(), null, null, true);



                            //绘制子区域
                            districtExplorer.renderSubFeatures(areaNode, function(feature, i) {

                                var fillColor = colors[i % colors.length];
                                var strokeColor = colors[colors.length - 1 - i % colors.length];

                                return {
                                    cursor: 'default',
                                    bubble: true,
                                    strokeColor: strokeColor, //线颜色
                                    strokeOpacity: 1, //线透明度
                                    strokeWeight: 1, //线宽
                                    fillColor: fillColor, //填充色
                                    fillOpacity: 0, //填充透明度
                                };
                            });


                        });




                        //绘制区域面板的节点
                        function renderAreaPanelNode(ele, props, color) {

                            var $box = $('<li/>').addClass('lv_' + props.level);

                            var $h2 = $('<h2/>').addClass('lv_' + props.level).attr({
                                'data-adcode': props.adcode,
                                'data-level': props.level,
                                'data-children-num': props.childrenNum || void(0),
                                'data-center': props.center.join(',')
                            }).html(props.name).appendTo($box);

                            if (color) {
                                $h2.css('borderColor', color);
                            }

                            //如果存在子节点
                            if (props.childrenNum > 0) {

                                //显示隐藏
                                $('<div class="showHideBtn"></div>').appendTo($box);

                                //子区域列表
                                $('<ul/>').addClass('sublist lv_' + props.level).appendTo($box);

                                $('<div class="clear"></div>').appendTo($box);

                                if (props.level !== 'country') {
                                    $box.addClass('hide-sub');
                                }
                            }

                            $box.appendTo(ele);
                        }


                        //填充某个节点的子区域列表
                        function renderAreaPanel(areaNode) {

                            var props = areaNode.getProps();

                            var $subBox = $('#area-tree').find('h2[data-adcode="' + props.adcode + '"]').siblings('ul.sublist');

                            if (!$subBox.length) {
                                //父节点不存在，先创建
                                renderAreaPanelNode($('#area-tree'), props);
                                $subBox = $('#area-tree').find('ul.sublist');
                            }

                            if ($subBox.attr('data-loaded') === 'rendered') {
                                return;
                            }

                            $subBox.attr('data-loaded', 'rendered');

                            var subFeatures = areaNode.getSubFeatures();

                            //填充子区域
                            for (var i = 0, len = subFeatures.length; i < len; i++) {
                                renderAreaPanelNode($subBox, areaNode.getPropsOfFeature(subFeatures[i]), colors[i % colors.length]);
                            }
                        }

                        //绘制某个区域的边界
                        function renderAreaPolygons(areaNode) {

                            //更新地图视野
                            map.setBounds(areaNode.getBounds(), null, null, true);

                            //清除已有的绘制内容
                            districtExplorer.clearFeaturePolygons();

                            //绘制子区域
                            districtExplorer.renderSubFeatures(areaNode, function(feature, i) {

                                var fillColor = colors[i % colors.length];
                                var strokeColor = colors[colors.length - 1 - i % colors.length];

                                return {
                                    cursor: 'default',
                                    bubble: true,
                                    strokeColor: strokeColor, //线颜色
                                    strokeOpacity: 1, //线透明度
                                    strokeWeight: 1, //线宽
                                    fillColor: fillColor, //填充色
                                    fillOpacity: 0.95, //填充透明度
                                };
                            });

                            //绘制父区域
                            districtExplorer.renderParentFeature(areaNode, {
                                cursor: 'default',
                                bubble: true,
                                strokeColor: 'black', //线颜色
                                strokeOpacity: 1, //线透明度
                                strokeWeight: 1, //线宽
                                fillColor: '#0c1f34', //填充色
                                fillOpacity: 0, //填充透明度
                            });
                        }

                        //切换区域后刷新显示内容
                        function refreshAreaNode(areaNode) {

                            districtExplorer.setHoverFeature(null);

                            renderAreaPolygons(areaNode);

                            //更新选中节点的class
                            var $nodeEles = $('#area-tree').find('h2');

                            $nodeEles.removeClass('selected');

                            var $selectedNode = $nodeEles.filter('h2[data-adcode=' + areaNode.getAdcode() + ']').addClass('selected');

                            //展开下层节点
                            $selectedNode.closest('li').removeClass('hide-sub');

                            //折叠下层的子节点
                            $selectedNode.siblings('ul.sublist').children().addClass('hide-sub');
                        }

                        //切换区域
                        function switch2AreaNode(adcode, callback) {

                            if (currentAreaNode && ('' + currentAreaNode.getAdcode() === '' + adcode)) {
                                return;
                            }

                            loadAreaNode(adcode, function(error, areaNode) {

                                if (error) {

                                    if (callback) {
                                        callback(error);
                                    }

                                    return;
                                }

                                currentAreaNode = window.currentAreaNode = areaNode;

                                //设置当前使用的定位用节点
                                districtExplorer.setAreaNodesForLocating([currentAreaNode]);

                                refreshAreaNode(areaNode);

                                if (callback) {
                                    callback(null, areaNode);
                                }
                            });
                        }

                        //加载区域
                        function loadAreaNode(adcode, callback) {

                            districtExplorer.loadAreaNode(adcode, function(error, areaNode) {

                                if (error) {

                                    if (callback) {
                                        callback(error);
                                    }

                                    console.error(error);

                                    return;
                                }

                                renderAreaPanel(areaNode);

                                if (callback) {
                                    callback(null, areaNode);
                                }
                            });
                        }

                        $('#area-tree').on('mouseenter mouseleave', 'h2[data-adcode]', function(e) {

                            if (e.type === 'mouseleave') {
                                districtExplorer.setHoverFeature(null);
                                return;
                            }

                            var adcode = $(this).attr('data-adcode');

                            districtExplorer.setHoverFeature(currentAreaNode.getSubFeatureByAdcode(adcode));
                        });


                        $('#area-tree').on('click', 'h2[data-children-num]', function() {

                            var adcode = $(this).attr('data-adcode');

                            switch2AreaNode(adcode);
                        });

                        $('#area-tree').on('click', '.showHideBtn', function() {

                            var $li = $(this).closest('li');

                            $li.toggleClass('hide-sub');

                            if (!$li.hasClass('hide-sub')) {

                                //子节点列表被展开
                                var $subList = $li.children('ul.sublist');

                                //尚未加载
                                if (!$subList.attr('data-loaded')) {

                                    $subList.attr('data-loaded', 'loading');

                                    $li.addClass('loading');

                                    //加载
                                    loadAreaNode($li.children('h2').attr('data-adcode'), function() {

                                        $li.removeClass('loading');
                                    });
                                }
                            }
                        });

                        //杭州
                        switch2AreaNode(330100);
                    });
                    var z = ["aa", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", 'm'];
                    for (var j = 0; j < 14; j++) {
                        $("#" + z[j] + "1 h2").html(is0ornot(data[j][0]));
                        $("#" + z[j] + "2 h2").html(is0ornot(data[j][1]));
                        $("#" + z[j] + "3 h2").html(is0ornot(data[j][3]));
                        $("#" + z[j] + "4 h2").html(is0ornot(data[j][4]));
                        $("#" + z[j] + "5 h2").html(is0ornot(data[j][2]));
                        $("#" + z[j] + "6 h2").html(is0ornot((parseFloat(data[j][5]) + parseFloat(data[j][6]))));
                    }
                }
            })
        }
        showProvince();

        // 使用刚指定的配置项和数据显示图表。
        // myChart.setOption(option);
        window.addEventListener("resize", function() {
            myChart.resize();
        });
    }

})